#include "TestSample.h"

#include <Common/codeperformance.h>

USING_NAMESPACE_OXGE
#define PrintConsol(x) std::cout << (x) << std::endl;
#define PrintLine std::cout<<std::endl;


void MathTestSample::TestVector2()
{
	
	PrintConsol("Testing Vector2");

	typedef Vector2 TestVectorType;
	const Real dScal = 8; 
	
	Vector2 v2;	



	PrintLine
	
}

void MathTestSample::TestVector3()
{

	PrintConsol("Testing Vector3");

	typedef Vector3 TestVectorType;
	const Real dScal = 34; 
	TestVectorType v1 = TestVectorType(5,5,0);
	TestVectorType v2 = TestVectorType::UNIT_X;

	PrintConsol(v1 + v2);
	PrintConsol(v1 - v2);
	PrintConsol( v1.dot(v2) );
	PrintConsol( v1 * dScal );
	PrintConsol( v2 * dScal );
	PrintConsol( TestVectorType::UNIT_X.cross(TestVectorType::UNIT_Y) );

	PrintLine
}

void MathTestSample::TestVector4()
{

}

void MathTestSample::TestMatrix2()
{
	PrintConsol("Testing Matrix2");

	typedef Matrix2 TestMatrixType;
	TestMatrixType tMat1 = TestMatrixType::IDENTITY;
	
	tMat1.SetRow(0, Vector2(1,2) );
	tMat1.SetCol(0, Vector2(7,8) );

	TestMatrixType inverMat = tMat1.GetInverse();
	PrintConsol(tMat1);
	PrintConsol(tMat1^3);
	PrintConsol(tMat1^-3);

	PrintConsol( (tMat1^3) * (tMat1^-3) );
	PrintConsol(inverMat);	
	PrintConsol( inverMat.GetInverse() );
	PrintConsol( inverMat * tMat1 );
	PrintConsol( tMat1 * inverMat );
	
	PrintConsol( (inverMat * tMat1) * (tMat1 * inverMat) )

	PrintLine
}

void MathTestSample::TestMatrix3()
{
	PrintConsol("Testing Matrix3");

	typedef Matrix3 TestMatrixType;
	
	
	TestMatrixType tMat1 = TestMatrixType::IDENTITY;
	tMat1.Set( 1,2,3,
				4,7,6,
				7,8,9);

	PrintConsol(tMat1);
	
	BEGIN_PERFORMANCE_ANALYSIS("Matrix 3 ")
		PrintConsol(tMat1^3);
		PrintConsol(tMat1^-3);
	END_PERFORMANCE_ANALYSIS


	PrintConsol(tMat1.GetInverse());
	PrintConsol(tMat1.GetInverse() * tMat1 );
	PrintConsol(tMat1 * tMat1.GetInverse() );
	
	PrintConsol(tMat1.GetSubMatrix(0,0));

}

void MathTestSample::TestMatrix4()
{
	PrintConsol("Testing Matrix4");

	typedef Matrix4 TestMatrixType;
	TestMatrixType tMat1 = TestMatrixType::IDENTITY;
	
	tMat1.Set(1,5,7,9,
			  4,5,2,1,
			  9,8,7,6,
			  3,5,7,6);

	
	TestMatrixType tMat2(2,4,3,0,
						 1,13,3,5,
						 2,1,5,6,
						 1,6,3,0);

	BEGIN_PERFORMANCE_ANALYSIS("Matrix4");
		TestMatrixType matx =  tMat1.GetTranspose()* tMat1 ;
		TestMatrixType maty = tMat2.GetTranspose() * tMat2;

		PrintConsol(matx);
		PrintConsol(maty);
		
			PrintConsol(matx * maty -  maty*matx );
		
		

		

	END_PERFORMANCE_ANALYSIS

	PrintConsol(tMat1);
	PrintConsol(tMat1.GetInverse());
	PrintConsol(tMat1.GetInverse() * tMat1 );
	PrintConsol(tMat1 * tMat1.GetInverse() );

	PrintConsol(tMat1.GetSubMatrix(0,0));
}

void oxge::MathTestSample::TestQuatation()
{
	PrintConsol("Testing Quaternion ... ");

	Quaternion quat1(1,2,3,5);
	Quaternion quat2(4,5,8,9);

	

	PrintConsol( (quat1*quat2).GetMatrix() );
	PrintConsol( quat1.GetMatrix()*quat2.GetMatrix() );



}

